<?php 
namespace Admin\Model;
use Think\Model;

class PluginsMsgModel extends Model {
	
	protected $_validate = array(
			array('name', 'require' ,'插件标识必须填写！', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
			array('name', '/^[a-zA-Z][\w_]{1,19}$/', '插件名称不合法',self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
			array('name', '', '插件名称已经存在！', self::MUST_VALIDATE, 'unique', self::MODEL_INSERT),
			array('title', 'require', '插件标题必须填写', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
			array('title', '1,50', '插件标题长度不能超于50字符', self::MUST_VALIDATE, 'length', self::MODEL_BOTH)
	);
	
	protected $_auto = array(
			array('create_time', NOW_TIME, self::MODEL_INSERT),
			array('update_time', NOW_TIME, self::MODEL_BOTH),
			array('status','1',self::MODEL_INSERT),
	);
	
	function info($id) {
		if (is_numeric($id)) {
			$map['id'] = $id;
		}else {
			$map['name'] = $id;
		}
		return $this->where($map)->find();
	}
}